package com.ruiboyun.liveapp.presenter.impl;

import com.ruiboyun.liveapp.bean.ReviewEntity;
import com.ruiboyun.liveapp.http.OkHttpManager;
import com.ruiboyun.liveapp.http.OnResponseListener;
import com.ruiboyun.liveapp.presenter.ReviewPresenter;
import com.ruiboyun.liveapp.util.tool.Loger;
import com.ruiboyun.liveapp.view.BaseView;
import com.ruiboyun.liveapp.view.ReviewView;

/**
 * Created by wushiqian on 2017/9/17.
 */

public class ReviewPresenterImpl extends BasePresenterImpl implements ReviewPresenter {
    public ReviewPresenterImpl(BaseView baseView) {
        super(baseView);
    }

    @Override
    public void getReview(String clientId,String channelId) {
        OkHttpManager.getInstance().getReviews(clientId, channelId, new OnResponseListener<ReviewEntity>() {
            @Override
            public void Success(ReviewEntity reviewEntity) {
                getView().getReviewSuccess(reviewEntity);
            }

            @Override
            public void onFailed(int errorCode) {
              getView().getReviewError(errorCode);
                getView().showTips("系统异常");
                Loger.e(errorCode+"review");
            }

            @Override
            public void onException(String msg) {
                getView().showTips(msg);
                Loger.e(msg+"review");
            }
        });
    }

    @Override
    public ReviewView getView() {
        return (ReviewView) baseView;
    }
}
